/**
 * 
 */
package com.nari.basic.dao;

import java.util.List;

import com.nari.basic.model.IRoleMenu;
import com.nari.coreframe.dao.hibernate3.GenericDaoImpl;

/**
 * 
 * @author Xiaopeng
 * @date 2013-7-18
 */
public class RoleMenuDaoImpl extends GenericDaoImpl<IRoleMenu, String> 
		implements IRoleMenuDao {
	
	/**
	 * 通过菜单删除角色菜单关联信息
	 * @param menuID
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-25
	 */
	public void deleteByMenuID(String menuID) throws Exception {
		String hsql = "delete from IRoleMenu rm " +
				"where rm.menuUuid='"+menuID+"'";
		this.runFormatHSql(hsql);
	}
	
	/**
	 * 通过角色唯一标识删除角色菜单关联信息
	 * @param roleUID
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-26
	 */
	public void deleteByRoleUID(String roleUID) throws Exception {
		String hsql = "delete from IRoleMenu rm " +
				"where rm.roleUuid='"+roleUID+"'";
		this.runFormatHSql(hsql);
	}
	
	/**
	 * 查询为角色授权的菜单ID
	 * @param roleUID 角色唯一标识
	 * @return
	 * @throws Exception
	 * @author Xiaopeng
	 * @date 2013-7-30
	 */
	public List<Object> queryMenuIDByRoleUID(String roleUID) throws Exception {
		if(roleUID!=null && !"".equals(roleUID.trim())) {
			String hsql = "select rm.menuUuid " +
					"from IRoleMenu rm " +
					"where rm.roleUuid='"+roleUID+"'";
			return this.runQueryHSqlObject(hsql);
		}
		return null;
	}
}
